/**
 * Created by jiexin on 2017/11/10.
 */
  layui.use(['form', 'element', 'layer', 'upload'], function() {
    var form = layui.form;
    var element = layui.element;
    var $ = layui.jquery;
    var layer = layui.layer; //弹层
    var upload = layui.upload;

    console.log(alldata);
    // if (alldata[4] !== null && alldata[4] !== ""){
    //     var img_file = 'http://localhost:8000/static/images/head/' + alldata[4];
    //     $("#headimg").attr('src', img_file)
    // }
    for (var i=0; i < alldata.length; i++){
        if (alldata[i] !== null && alldata[i] !== ""){
            userdetails(i,alldata[i])
        }
    }
    function userdetails(dstatus, ddata) {
        if (dstatus === 1){
            $("#spanemail").text(ddata)
        }else if (dstatus === 2){
            $("#spancreate").text(ddata)
        }else if (dstatus === 3){
            $("#spanuser").text(ddata)
        }else if (dstatus === 4){
            var img_file = 'http://localhost:8000/static/images/head/' + ddata;
            $("#headimg").attr('src', img_file)
        }

    }


    var img_upload = upload.render({
        elem: '#imgupload'
        // ,data:{"dir_file":tree_dir_file}
        ,url: '/img-upload/'
        ,accept: 'images' //普通文件
        ,size: 100
        ,done: function(res){
            if (res["status"] === 0){
                layer.msg("图片添加成功");
                var img_file = 'http://localhost:8000/static/images/head/' + res['imgfile'];
                $("#headimg").attr('src', img_file);
            }else{
                layer.msg("请选择图片")
            }
        }
    });
});